package com.iot.manage.service;

import com.alibaba.fastjson.JSONObject;
import com.iot.manage.dao.GatewayMapper;
import com.iot.manage.pojo.Gateway;
import com.iot.manage.pojo.SysCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GatewayService {

    @Autowired
    private GatewayMapper gatewayMapper;

    public List<Gateway> findGatewayList(String query, int pagenum, int pagesize) {
        return gatewayMapper.findGatewayList(query,pagesize * (pagenum - 1),pagesize * pagenum);
    }

    public int countGatewayList(String query) {
        return gatewayMapper.countGatewayList(query);
    }

    public List<SysCode> findGatewayParentCodeList() {
        return gatewayMapper.findGatewayParentCodeList();
    }

    public List<SysCode> findGatewayTypeList() {
        return gatewayMapper.findGatewayTypeList();
    }

    public void addGatewayInfo(JSONObject params) {
        gatewayMapper.addGatewayInfo(params);
    }


    public Gateway findGatewayInfoByIdOrCode(String params) {
        return gatewayMapper.findGatewayInfoByIdOrCode(params);
    }

    public void updateGatewayInfo(JSONObject params) {
        gatewayMapper.updateGatewayInfo(params);
    }

    public void removeGatewayInfo(String gatewayId) {
        gatewayMapper.removeGatewayInfo(gatewayId);
    }

    public int countGatewayParentById(String gatewayId) {
        return gatewayMapper.countGatewayParentById(gatewayId);
    }

    public void updateGatewayParent(String gatewayId) {
        gatewayMapper.updateGatewayParent(gatewayId);
    }
}
